home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Advanced I⁄O v2.3 / Advanced i⁄o / myenv.h < prev    next >
Text File  |  1995-06-05  |  2KB  |  87 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. //************************************************************************
  3. //
  4. //            A standard environment
  5. //              I am accustomed to
  6. //
  7. // $Id: myenv.h,v 1.3 1995/02/08 17:23:51 oleg Exp oleg $
  8.  
  9. #ifndef __GNUC__
  10. #pragma once
  11. #endif
  12. #ifndef _myenv_h
  13. #define _myenv_h
  14.  
  15. #ifdef __GNUC__
  16. #pragma interface
  17. #endif
  18.  
  19.                 /* Strings of symbols            */
  20.                 /* They may be used as a delimiting lines*/
  21. extern const char _Minuses [];
  22. extern const char _Asteriscs [];
  23. extern const char _Equals [];
  24.  
  25.                 /* Print an error message at stderr and    */
  26.                 /* abort                */
  27. volatile void _error(
  28.     const char * message,        /* Message to be printed    */
  29.     ...                             /* Additional args to printf    */
  30.        );
  31.  
  32.                 /* Print a message at stderr         */
  33. void message(
  34.     const char * text,        /* Message to be printed    */
  35.     ...                             /* Additional args to printf    */
  36.        );
  37.  
  38. //------------------------------------------------------------------------
  39. //            Patches to the standard environment
  40.  
  41.                                 // Like strncpy(), but ALWAYS terminates
  42.                                 // the destination string
  43. char * xstrncpy(char * dest, const char * src, const int len);
  44.  
  45. inline long int sqr(const int x)        { return x*x; }
  46.  
  47.                 // Uncomment if the compiler sucks
  48. #ifdef __MWERKS__
  49. #define bool Boolean
  50. #endif
  51. #if 0
  52. enum bool {false,true};
  53. #endif
  54.  
  55.  
  56.                                 // libg++ nifty timing functions
  57.                                 // return_elapsed_time(Last_time) returns
  58.                                 // process time (in secs) since Last_Time
  59.                                 // If Last_time == 0.0, return time since
  60.                                 // the last call to start_timer()
  61. #ifndef __GNUC__
  62. double start_timer(void);
  63. double return_elapsed_time(const double Last_Time);
  64. #endif
  65.  
  66.  
  67. //------------------------------------------------------------------------
  68. //            Verify the assertion
  69.  
  70. #if 0
  71.                       /* Print a message and abort*/
  72. extern volatile void _error( const char * message,... ); 
  73. #endif
  74.  
  75. #define assert(ex) \
  76.         (void)((ex) ? 1 : \
  77.               (_error("Failed assertion " #ex " at line %d of `%s'.\n", \
  78.                __LINE__, __FILE__), 0))
  79. #define assertval(ex) assert(ex)
  80.  
  81. #define assure(expr,message)                \
  82.     if    (expr) ;                \
  83.     else _error("%s\n at line %d of '%s'.",message,__LINE__, __FILE__)
  84.  
  85.  
  86. #endif
  87.